package com.mall.server;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @author : xyiaao
 * @createDate : 2022/3/30 9:38
 */
@SpringBootApplication
public class ServerApplication {

    public static void main(String[] args) {

        SpringApplication.run(ServerApplication.class, args);
    }


    @Value("${redisson.url}")
    private String redissonUrl;


    /**
     * redisson Bean
     *
     * @return
     */
    @Bean
    public Redisson redisson() {

        Config config = new Config();
        config.useSingleServer().setAddress(redissonUrl);
        RedissonClient redisson = Redisson.create(config);
        return (Redisson) redisson;
    }

    @Bean

    public BCryptPasswordEncoder bcryptPasswordEncoder() {

        return new BCryptPasswordEncoder();

    }

}
